import request from '@/assets/utils/request'
import type {AxiosPromise} from 'axios'

/**
 * 注册短信验证码发送
 * @param mobile 手机号码
 */
export const sendCode = (mobile: string): AxiosPromise => request.get('login/social/code', {mobile})

/**
 * 绑定手机号
 * @param code 短信验证码
 * @param mobile 手机号码
 * @param unionId 第三方标识
 */
export const bindMobile = (code: string, mobile: string, unionId: string): AxiosPromise =>
  request.post('login/social/bind', {code, mobile, unionId})

/**
 * 完善用户信息
 * @param account 账号
 * @param code 短信验证码
 * @param mobile 手机号码
 * @param password 密码
 * @param unionId 第三方标识
 */
export const saveUserData = (account: string, code: string, mobile: string, password: string, unionId: string): AxiosPromise =>
  request.post(`login/social/${unionId}/complement`, {account, code, mobile, password, unionId})